<template>
	<div class="app-add">
		<a-form
			ref="formRef">{{ validateInfos }}
			<div class="message-top">
				<div class="appcon-650">
					<h1 class="center">在线帮助</h1>
					<InputCell v-model:value="formDTO.basicInfoForm.subject" :config="{
						type: 'default',
						labelName: '主题',
						hasError: true,//是否加红色星号
						name: ['basicInfoForm', 'subject']
					}"/>
				</div>
				<div class="appcon-350">
					<p><span class="txt">申请编号</span><span class="cont">{{formDTO.basicInfoForm.appCode}}</span></p>
					<p><span class="txt">申请日期</span><span class="cont">{{formatDate(new Date())}}</span></p>
					<p><span class="txt">起草人</span><span class="cont">{{formDTO.basicInfoForm.drafter}}</span></p>
				</div>
			</div>
			<div class="error-main" v-if="errorList && errorList.length !== 0">
				<div class="validate-messages-title">错误信息:</div>
				<span class="validate-messages-close" @click="closeError"></span>
				<ul class="validate-messages-list">
					<li class="error-message" v-for="(item, index) in errorList" :key="index">{{ item.errors&&item.errors[0] }}</li>
				</ul>
			</div>
			<div class="message-main">
				<div class="tags">
					<div class="nav" v-for="item in menuList" @click="switchTab(item.actionType)" :key="item.actionType" :class="[item.actionType === currentActionType ? 'nacative' : '']">{{ item.name }}</div>
				</div>
				<div v-show="currentActionType === 'CREATE'">
					<a-collapse v-model:activeKey="showCreate">
						<a-collapse-panel v-for="(item, index) in config.filter(i=> i.hhgColumn === 'CREATE')" :key="index + 1" :header="item.hhgTitle">
							<div class="colItem">
								<div class="appcon" v-for="(subItem, subIndex) in item.hhgList" :class="'hhg-coloum-' + subItem.hhgCol" :key="subIndex">
									<HhgInputMember v-model:value="formDTO.basicInfoForm.requester" @fuzzySearch="fuzzySearchMember" @selectedMember="selectedSingleMember" @onClickPopup="onClickPopupSelectMember" @clearMebmer="clearApplyMebmer" v-bind="attrs" v-if="subItem.hhgType === 'inputMember'" :config="{
										isRead: false,
										memberList,
										labelName: '申请人',
										hasError: true,//是否加红色星号
										displayList,
										options: optionsSingleMember,
										name: ['basicInfoForm', 'requester'],
										title: '选择成员',
										subTitle: '待选人员（您可以通过搜索查询人员）'
									}"/>
									<SelectCell :value="formDTO.basicInfoForm.requesterDept" mode="multiple" :field-names="{ label: 'name', value: 'id' }" v-if="subItem.hhgType === 'select'" :config="subItem.config" @change="selectFun($event, 'basicInfoForm', 'requesterDept')"
									:options="[
										{ id: '1', name: 'ME&S/SH Site/FAB II/ENG II/TF&IIM&PVD/PVD&CVD EE ME&S/SH Site' },
										{ id: '2', name: 'SH Site' },
										{ id: '3', name: 'FAB II' },
										{ id: '12', name: 'TF&IIM&PVD' },
										{ id: '13', name: '测试1' },
										{ id: '15', name: '测试1' },
										{ id: '16', name: '测试2' }
									]"/>
									<InputCell :value="subItem.hhgKey.length === 1 ? formDTO[subItem.hhgKey[0]] : formDTO[subItem.hhgKey[0]]?.[subItem.hhgKey[1]]" v-if="subItem.hhgType === 'input'" :config="subItem.config" @input="inputFun($event, subItem.hhgKey)"/>
									<TextareaCell v-if="subItem.hhgType === 'textArea'" :value="subItem.hhgKey.length === 1 ? formDTO[subItem.hhgKey[0]] : formDTO[subItem.hhgKey[0]]?.[subItem.hhgKey[1]]" :disabled="false" @input="inputFun($event, subItem.hhgKey)" :config="{
										labelName: '描述',
										name: ['helpInfo', 'description']
									}"/>
									<HhgMixedSelectionMember v-if="subItem.hhgType === 'mixedMember'" @fuzzySearch="fuzzySearch" @SwitchTab="SwitchTabMixed" @onClickPopup="onClickPopupMixedMember" @removeFn="readersRemoveFn" @selectedMember="mixedSelectedMember" @clearMixedMebmer="readersClearMixedMebmer" v-model="formDTO.helpInfo.readers" :list="list" :config="{
										labelName: '阅读者',
										name: ['helpInfo', 'readers'],
										displayList: formDTO.helpInfo.readers,
										isRead: false,
										options: optionsMixed
									}">
										<template #header> <!-- 针对 header 插槽 -->
											<p>这是 header 插槽的内容。</p>
										</template>
										<template #footer> <!-- 针对 footer 插槽 -->
											<p>这是 footer 插槽的内容。</p>
										</template>
									</HhgMixedSelectionMember>
									<UploadCell ref="uploadRef" v-if="subItem.hhgType === 'upload'" v-model="formDTO.attachmentDocs" @nodeClick="nodeClick" @uploadSucces="uploadSucces"
										:config="{
											labelName: '正文附件',
											isRead: false,
											deleteTipsTitle: '确定删除当前文件？',
											okText: '确定',
											cancelText: '取消',
											hasList: [],
											name: 'attachmentDocs',
											multiple: false,
											uploadUrl: '/upload',
											fileAccept,
											// fileSize,
											errorTipsText: `文件类型不正确，请选择${JSON.stringify(fileAccept)}类型的文件`,
											errorTipsSize,
											/* 以下是传给上传接口的参数 */
											jsonApi: {
												appCode: hhgAppCode,
												type: hhgType,
												processId: hhgProcessId
											}
										}"/>
								</div>
							</div>
						</a-collapse-panel>
					</a-collapse>				
				</div>
				<div v-show="currentActionType === 'APPROVAL'">
					<a-collapse v-model:activeKey="showAPPROVAL">
						<a-collapse-panel v-for="(item, index) in config.filter(i=> i.hhgColumn === 'APPROVAL')" :key="index + 1" :header="item.hhgTitle">
							<template #extra v-if="item.hhgSloTextra">
								<div class="formHeadRight" @click.stop>
									<div class="bpm">
										<span>查看BPM流程图</span>
									</div>
									<div class="bpm">
										<span>查看流程图</span>
									</div>
								</div>
							</template>
							<div class="appcon" v-for="(subItem, subIndex) in item.hhgList" :class="'hhg-coloum-' + subItem.hhgCol" :key="subIndex">
								<div class="theme">
									<HhgRadioMember
									v-if="subItem.hhgType === 'radioMember'"
									:list="radioMemberList"
									:radioList="radioList"
									:mixedList="radioMixedMemberList"
									:config="{
										labelName: '审批决策',
										name: 'approvalDecision',
										isRead: false,
										multiple: false,
										options: optionsRadio
									}"
									@onClickPopup="onClickPopupRadioSingleMember" @onClickPopupRadioMixed="onClickPopupRadioMixedMember" @SwitchTab="SwitchTabRadio"
									@fuzzySearchMemberMixedRadio="fuzzySearchMemberMixedRadio" @selectedMemberMixedRadio="selectedMemberMixedRadio" @clearMixedMebmerRadio="clearMixedMebmerRadio" @removeFn="removeFn"
									@fuzzySearchMember="fuzzySearchRadioMember" @selectedSingleMember="selectedRadioSingleMember" @clearApplyMebmer="clearRadioApplyMebmer"/>
									<div class="appcon-12" v-if="subItem.hhgType === 'radioMember'">
										<div class="hhg-themeFlex">
											<div class="theme-label2">当前审批人</div>
											<div class="uploadList">
												<div class="theme-txt">
													<span class="txt">马佳俊,Martin Ma(005213)</span>
												</div>
											</div>
										</div>
									</div>
									<div class="appcon-12" v-if="subItem.hhgType === 'radioMember'">
										<div class="hhg-themeFlex">
											<div class="theme-label3">当前状态</div>
											<div class="uploadList">
												<div class="theme-txt">
													<span class="txt">申请人主管审批</span>
												</div>
											</div>
										</div>
									</div>
									<TableBase v-show="subItem.hhgType === 'recordTable'" :dataSources="dataSource" :columns="columns" :pagination="false" v-bind="tableAttrs" :className="'baseTable2'"/>
								</div>
							</div>
						</a-collapse-panel>
						
					</a-collapse>
				</div>				
			</div>
			<div class="navright">
				<HhgFormOperation @submitCreate="submitCreate" @saveCreate="saveCreate" @reversionCreate="reversionCreate"
					:config="{
					list: operationList
				}"/>
			</div>
		</a-form>
	</div>

</template>
<script setup>
import { ref, useAttrs, reactive, onMounted, watch, computed } from 'vue'
import { Message } from "ant-design-vue"
import { getMemberList, getGroupList, getOrganizationList, getRecordList, createData } from '@/api/data'
import { mapRecursive, buildTree, formatDate, convertBytesToMB } from '@/utils/index'
import { requesterRules, initRules } from '@/utils/rules'
import { TableColumns } from "@/utils/tableConfig"
import InputCell from "@/components/hhg-input/hhg-input"
import HhgMixedSelectionMember from '@/components/hhg-mixedSelectionMember/hhg-mixedSelectionMember'
import HhgInputMember from '@/components/hhg-inputSingleMember/hhg-inputSingleMember'
import HhgRadioMember from '@/components/hhg-radioMember/hhg-radioMember'
//右侧操作按钮
import HhgFormOperation from '@/components/hhg-formOperation/hhg-formOperation'
// 基本表格
import TableBase from '@/components/hhg-tableBase/hhg-tableBase'
import SelectCell from '@/components/hhg-select/hhg-select'
import TextareaCell from '@/components/hhg-textarea/hhg-textarea'
/*上传*/
import UploadCell from '@/components/hhg-upload/hhg-upload'
/* JSON配置 */
import { hhgConfig, setValueByPath } from './Config'
/* useform表单验证 */
import { Form } from 'ant-design-vue'

//属性穿透
const attrs = useAttrs()
const tableAttrs = useAttrs()

//taskInfo基本数据
const taskInfo = reactive({
	activityId: "HELP_PUB_RequesterManager",
	taskId: "5704d4b0-a591-11ef-a2ba-9a82fdefadcd"
})

const formDTO = reactive({
	basicInfoForm: {
		pid: "",
		appCodeRef: "",
		instanceId: "",
		siteCode: "",
		fabCode: "",
		companyCode: "",
		appCode: "HELP-2024-0024-1",
		processId: "HELP_HelpPublishProcess",
		version: "",
		subject: "",
		drafter: "jimi",
		drafterTel: "",
		requesterDept: ['1'],
		formType: "HelpPublishProcess"
	},
	helpInfo: {
		type: "",
		readers: [
		{
			id: '500118',
			displayName: '安博源,Boyuan An',
			jobLevel: '6',
			type: 'emp'
		}]
	},
	attachmentDocs: [],
	approvalDecision: ''
})
// 默认展开
const showCreate = ref(['1', '2'])
const showAPPROVAL = ref(['1', '2'])

//右侧操作按钮start
//表单验证事件
const errorList = ref([])
const formRef = ref()

// 关闭错误
const closeError = ()=> {
	errorList.value = []
}
const hhgTrigger = ref('submit')
const hhgFun = ref([])
// 验证规则
const rulesCustom = ref(requesterRules(initRules, formDTO, hhgTrigger.value, hhgFun.value))

/*useform表单验证*/
const useForm = Form.useForm
const {

validate: sum_Validate,

validateInfos: sum_ValidateInfos,

} = useForm( formDTO , rulesCustom)
const sum_ErrorInfos = computed(() =>sum_ValidateInfos)
watch([sum_ErrorInfos],()=>{
	console.log('sum_ErrorInfos', sum_ErrorInfos.value)
})

//审批栏的操作

const approvalSubmit = async (params)=> {
	const { submitType, actionType, decision, remark } = params
	taskInfo['decision'] = decision
	taskInfo['remark'] = remark
	const data = {
		submitType,
		actionType,
		formDTO,
		taskInfo
	}
	
	const res = await createData(data)
	if (res.code) {
		Message.success(res.data.message)
	}
}

const operationList = ref([
	{ label: '提交', clsName: "item-submit", btnName: "btn-submit", callback: ()=> {
		// rulesCustom.value = customRules(['helpInfo', 'description'], true, (rule, value, callback)=> {
		// 	if (value.length !== 1) {
		// 		console.log(rule)
		// 		callback(new Error(`描述必须是一位数字.`))
		// 	} else {
		// 		callback()
		// 	}
		// }, '描述必填2222.')
		rulesCustom.value = requesterRules(initRules, formDTO, hhgTrigger.value, hhgFun.value)
		// rulesCustom.value = customRules(['attachmentDocs'], true, (rule, value, callback)=> {
		// 	if (value.length !== 1) {
		// 		callback(new Error(`公文附件有且只能有1个.`))
		// 	} else {
		// 		callback()
		// 	}
		// }, '公文附件有且只能有1个.')
		setTimeout(() => {
			sum_Validate()
			.then(async () => {
				errorList.value = []
				approvalSubmit({
					submitType: 'submit', actionType: 'CREATE', decision: 'CREATE', remark: '创建'
				})
			})
			.catch(error => {
				errorList.value = error.errorFields
				
				
			})
		}, 299)
	} },
	{ label: '保存', clsName: "item-save", btnName: "btn-save", callback: ()=> {
		formRef.value
		.validate()
		.then(async () => {
			errorList.value = []
			approvalSubmit({
				submitType: 'submit', actionType: 'CREATE', decision: 'CREATE', remark: '创建'
			})
		})
		.catch(error => {
			errorList.value = error.errorFields
			
			if (error.errorFields.some(item => Array.isArray(item.name) && item.name.includes("approvalDecision")) === false && currentActionType.value === 'APPROVAL') {
				approvalSubmit({
					submitType: 'submit', actionType: 'APPROVE', decision: 'Approve', remark: 'Approve'
				})
			}
		})
	} },
	{ label: '关闭', clsName: "item-close", btnName: "btn-close", callback() {
		// 检查是否有opener窗口
		if (window.opener && !window.opener.closed) {
			// 调用父页面
			window.opener.postMessage('close')
		}
		// 关闭当前窗口
		window.close()
	} },
	{ label: '打印', clsName: 'item-print', btnName: 'btn-print' },
	{ label: '删除', clsName: 'item-reversion', btnName: "btn-reversion", callback: ()=> {
		formRef.value
		.validate()
		.then(async () => {
			errorList.value = []
			approvalSubmit({
				submitType: 'submit', actionType: 'REVISION', decision: 'REVISION', remark: '改版'
			})
		})
		.catch(error => {
			errorList.value = error.errorFields
			if (error.errorFields.some(item => Array.isArray(item.name) && item.name.includes("approvalDecision")) === false && currentActionType.value === 'APPROVAL') {
				approvalSubmit({
					submitType: 'submit', actionType: 'APPROVE', decision: 'Approve', remark: 'Approve'
				})
			}
		})
	} },
	{ label: '改版', clsName: "item-applyread", btnName: "btn-applyread", callback: ()=> {
		formRef.value
		.validate()
		.then(async () => {
			errorList.value = []
			approvalSubmit({
				submitType: 'submit', actionType: 'REVISION', decision: 'REVISION', remark: '改版'
			})
		})
		.catch(error => {
			errorList.value = error.errorFields
			if (error.errorFields.some(item => Array.isArray(item.name) && item.name.includes("approvalDecision")) === false && currentActionType.value === 'APPROVAL') {
				approvalSubmit({
					submitType: 'submit', actionType: 'APPROVE', decision: 'Approve', remark: 'Approve'
				})
			}
		})
	} },
	{ label: '废版2', clsName: 'item-waste-version', btnName: "btn-abolish", callback: ()=> {} },
	{ label: '申请阅读权限', clsName: "item-applyread", btnName: "btn-applyread", callback: ()=> {} },
	{ label: '历史版本', clsName: "item-revision-history", btnName: "btn-versionHistory", callback: ()=> {} },
	{ label: '相关申请', clsName: "item-relatedApplication", btnName: "btn-relatedApplication", callback: ()=> {} },
	{ label: '历史下载', clsName: "item-history-download", btnName: "btn-historicalDownloads", callback: ()=> {} },
	{ label: 'TOP', clsName: "item-top", btnName: "btn-top", callback: ()=> {} }
])
//右侧操作按钮end

//上传组件start
const fileSize = ref(1024*1024)
const errorTipsSize = ref(`文件大小超过${convertBytesToMB(fileSize.value)}MB`)

const fileAccept = ref(['.doc', '.docx', '.xls', '.xlsx', '.ppt', '.rar', '.pdf', '.exe'])
const uploadRef = ref(null)
const hhgAppCode = ref('HELP')
const hhgType = ref('business')
const hhgProcessId = ref('HELP HelpPublishProcess')
const nodeClick = item => {
	console.log('单击获取的数据', item)
}
const uploadSucces = value=> {//上传成功的数据
	formDTO.attachmentDocs = value
	currentError()
}
// 上传组件end

//审批栏切换start
const menuList = ref([
	{ name: '申请栏', actionType: 'CREATE' },
	{ name: '审批栏', actionType: 'APPROVAL' }
])
const currentActionType = ref('CREATE')
const switchTab = (actionType)=> {
	currentActionType.value = actionType
}
//表头
const columns =  ref(TableColumns.SearchColumns)
const dataSource = ref([])
const haveRecordList = async ()=> {
	const res = await getRecordList()
	if (res.code) {
		dataSource.value = res.data.list
	}
}
//审批栏切换end

// 阅读者start
const list = ref([])
const optionsMixed = ref(null)
const organizationItem = (item)=> {
  return {
    pId: item.pId,
    id: item.id,
    name: item.displayName,
    code: item.code,
    label: item.displayName,
    value: item.id
  }
}
//弹出触发
const onClickPopupMixedMember = async ()=> {
	const type = optionsMixed.value
	if (type === 'emp' || !type) {
		list.value = localStorage.getItem('localMember') ? JSON.parse(localStorage.getItem('localMember')) : []
	}
	if (type === 'group') {
		list.value = localStorage.getItem('localGroup') ? JSON.parse(localStorage.getItem('localGroup')) : []
	}
	if (type === 'org') {
		const res = await getOrganizationList()
		if (res.code) {
			list.value = mapRecursive(buildTree(res.data.list), organizationItem)
		}
	}
}
// 初始化数据
const mixedSelectedMember = value=> {
	formDTO.helpInfo.readers = value
	
	currentError()
}
const readersClearMixedMebmer =()=> {//清空
	formDTO.helpInfo.readers = []
	currentError()
}
const readersRemoveFn = value=> {//删除选择数据
	formDTO.helpInfo.readers = value
	currentError()
}
const fuzzySearch = async (type, data)=> {
	
	if (type === 'emp') {
		const res = await getMemberList(data)
		if (res.code) {
			list.value = res.data.list
			
		}
	}
	if (type === 'group') {
		const res = await getGroupList(data)
		if (res.code) {
			list.value = res.data.list
		}
	}
	if (type === 'org') {
		const res = await getOrganizationList(data)
		if (res.code) {
			list.value = mapRecursive(buildTree(res.data.list), organizationItem)
			
		}
	}
}
const SwitchTabMixed = async type=> {
	if (type === 'emp') {
		list.value = localStorage.getItem('localMember') ? JSON.parse(localStorage.getItem('localMember')) : []
	}
	if (type === 'group') {
		list.value = localStorage.getItem('localGroup') ? JSON.parse(localStorage.getItem('localGroup')) : []
	}
	if (type === 'org') {
		const res = await getOrganizationList()
		if (res.code) {
			list.value = mapRecursive(buildTree(res.data.list), organizationItem)
		}
	}
}
// 阅读者end

//审批决策插件start
const radioMemberList = ref([])
const optionsRadio = ref(null)
const onClickPopupRadioSingleMember = ()=> {//选择成员弹出框触发
	radioMemberList.value = localStorage.getItem('localMember') ? JSON.parse(localStorage.getItem('localMember')) : []
}
const radioList = ref([
	{ value: 'Approve', label: '核可(Approve)', tip: '提示1',
		callback: (value)=> {
			
			formDTO.approvalDecision = value.value
		} 
	},
	{ value: 'Reject', label: '驳回(Reject)', tip: '提示2',
		callback: (value)=> {
			
			formDTO.approvalDecision = value.value
		} 
	},
	{ value: 'MoreApprove', label: '加签(More Approve)', lang: 'mixedMember', tip: '提示3',
		callback: (value)=> {
			
			formDTO.approvalDecision = value.value
		}
	},
	{ value: 'Transfer', label: '转办(Transfer)', lang: 'member', tip: '提示4',
		callback: (value)=> {
			
			formDTO.approvalDecision = value.value
		}
	}
])
const fuzzySearchRadioMember = async (data)=> {
	const res = await getMemberList(data)
	if (res.code) {
		radioMemberList.value = res.data.list
		
	}
}
const selectedRadioSingleMember = (value)=> {
	
	
	
	
	
	if (formDTO.approvalDecision === 'MoreApprove') {
		taskInfo.jobEditType['reassignList'] = value.data.data.map(i=> i.id).join(',')
	}
}
const clearRadioApplyMebmer = ()=> {//清空
	
}
const radioMixedMemberList = ref([])
const onClickPopupRadioMixedMember = ()=> {//混选弹出框触发
	radioMixedMemberList.value = localStorage.getItem('localMember') ? JSON.parse(localStorage.getItem('localMember')) : []
}
const SwitchTabRadio = async type=> {
	if (type === 'emp') {
		radioMixedMemberList.value = localStorage.getItem('localMember') ? JSON.parse(localStorage.getItem('localMember')) : []
	}
	if (type === 'group') {
		radioMixedMemberList.value = localStorage.getItem('localGroup') ? JSON.parse(localStorage.getItem('localGroup')) : []
	}
	if (type === 'org') {
		const res = await getOrganizationList()
		if (res.code) {
			radioMixedMemberList.value = mapRecursive(buildTree(res.data.list), organizationItem)
		}
	}
}
const fuzzySearchMemberMixedRadio = async (type, data)=> {
	if (type === 'emp') {
		const res = await getMemberList(data)
		if (res.code) {
			radioMixedMemberList.value = res.data.list
			
		}
	}
	if (type === 'group') {
		const res = await getGroupList(data)
		if (res.code) {
			radioMixedMemberList.value = res.data.list
		}
	}
	if (type === 'org') {
		const res = await getOrganizationList(data)
		if (res.code) {
			radioMixedMemberList.value = mapRecursive(buildTree(res.data.list), organizationItem)
			
		}
	}
}
const selectedMemberMixedRadio = value=> {
	if (formDTO.approvalDecision === 'MoreApprove') {
		console.log('数据', value)
	}
	//混选确定后得到的数据
}
const removeFn = value=> {
	console.log('删除后得到的数据', value)
}
const clearMixedMebmerRadio = () => {
	//混清空后后得到的数据
}
//审批决策插件end


//选择会员相关start
const memberList = ref([])
const optionsSingleMember = ref('emp')
const currentError = ()=> {
	rulesCustom.value = requesterRules(initRules, formDTO, hhgTrigger.value, hhgFun.value)
	setTimeout(() => {
		formRef.value.validateFields().catch((error) => {
			
			errorList.value = error.errorFields
		})
	}, 299)
	
}
const clearApplyMebmer = ()=> {
	formDTO.basicInfoForm.requester = ''
	currentError()
}
const onClickPopupSelectMember = async ()=> {
	const type = optionsSingleMember.value
	if (type === 'emp') {
		memberList.value = localStorage.getItem('localMember') ? JSON.parse(localStorage.getItem('localMember')) : []
	}
	if (type === 'group') {
		memberList.value = localStorage.getItem('localGroup') ? JSON.parse(localStorage.getItem('localGroup')) : []
	}
	if (type === 'org') {
		const res = await getOrganizationList()
		if (res.code) {
			memberList.value = mapRecursive(buildTree(res.data.list), organizationItem)
		}
	}
}
const fuzzySearchMember = async (value)=> {
	//其中type: group, emp, org, text是搜索框的内容，letters是字母
	const { type, text, letters } = value
	if (type === 'emp') {
		const res = await getMemberList({text, letters})
		if (res.code) {
			memberList.value = res.data.list
			
		}
	}
	if (type === 'group') {
		const res = await getGroupList({text, letters})
		if (res.code) {
			memberList.value = res.data.list
		}
	}
	if (type === 'org') {
		const res = await getOrganizationList({text, letters})
		if (res.code) {
			memberList.value = mapRecursive(buildTree(res.data.list), organizationItem)
			
		}
	}
}
const selectedSingleMember = (value)=> {
	formDTO.basicInfoForm.requester = value.name
	currentError()
}

/*JSON配置start*/
const config = ref(hhgConfig)
const selectFun = (value, key, subKey)=> {
	formDTO[key][subKey] = value
	currentError()
}
const inputFun = (event, item)=> {
	const value = event.target.value
	
	if (item.length === 1) {
		formDTO[item[0]] = value
	}
	if (item.length === 2) {
		formDTO[item[0]][item[1]] = value
	}
	currentError()
}
/*JSON配置end*/

//选择会员相关end
onMounted(()=> {
	//调用表格数据
	haveRecordList()
	/*JSON配置初始化*/
	// 遍历config，将hhgKey对应的值拓展到formDTO里
	config.value.forEach(item => {
		item.hhgList.forEach(subItem => {
			setValueByPath(formDTO, subItem.hhgKey, subItem.hhgValue)
		})
	})
})
</script>
<style lang="scss"></style>